package com.hellpro.lolbox.home.presenter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.List;

/**
 * Package_Name: com.hellpro.lolbox.home.presenter
 * Description :Vpde 适配器
 * author: HellPermanent
 * date:  2016/10/20 21:13
 * remarks：
 */
public class ZXVpAdapter extends FragmentPagerAdapter {
    //需要几条数据：tabtitle的list集合, fargment的集合；
    private List<String> mTitleList;
    private List<Fragment> mFragmentList;
    public ZXVpAdapter(FragmentManager fm) {
        super(fm);
    }

    public  void setData(List<String> titleList,List<Fragment> fragmentList ){
        mTitleList = titleList;
        mFragmentList =fragmentList;
        if (fragmentList!=null) {
            notifyDataSetChanged();
        }
    }

    @Override
    public Fragment getItem(int position) {
        return mFragmentList!=null?mFragmentList.get(position):null;
    }

    @Override
    public int getCount() {
        return mFragmentList!=null?mFragmentList.size():0;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return  mTitleList!=null?mTitleList.get(position):null;
    }
}
